package com.itheima.day17_反射和类加载器.Test01;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class ReflactDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        InputStreamReader isr = new InputStreamReader(new FileInputStream("homework\\src\\prop.properties"),"GBK");

        Properties prop = new Properties();
        prop.load(isr);

        String cn = prop.getProperty("className");
        String mn = prop.getProperty("methodName");

        Class name = Class.forName(cn);
        Constructor con = name.getConstructor();
        Object o = con.newInstance();
        Method method = name.getMethod(mn);
        method.invoke(o);
    }
}
